require.config({
    // urlArgs: "v=" + requirejs.s.contexts._.config.config.version,
    baseUrl: '/static/backend/js/', //资源基础路径
    packages: [{
        name: 'moment',
        location: '../libs/moment',
        main: 'moment'
    }],
    //在打包压缩时将会把include中的模块合并到主文件中
    include: ['css', 'layer', 'overlayScrollbars', 'backend', 'adminlte'],

    map: {
        '*': {
            'css': '../libs/require-css/css.min'
        }
    },
    paths: {
        //傲杰文件夹
        'aojie': './aojie/aojie',
        'perfect-scrollbar': './aojie/perfect-scrollbar.min',
        'lightyear': './aojie/lightyear',
        'form': './aojie/form',
        'upload': './aojie/upload',
        'editor': './aojie/kindeditor',
        //以下内容为libs文件
        'jquery': '../libs/jquery/dist/jquery.min',
        'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
        'toastr': '../libs/toastr/toastr',
        'validator-core': '../libs/nice-validator/dist/jquery.validator',
        'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
        'validator': 'require-validator',
        'axios': '../libs/axios/dist/axios.min',
        'layer': '../libs/layer/dist/layer',
        'chart': '../libs/chart.js/dist/Chart.min',
        'table': 'require-table',
        'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
        'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
        'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
        'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
        'bootstrap-table-jumpto': '../libs/bootstrap-table/dist/extensions/page-jumpto/bootstrap-table-jumpto',
        'webuploader': '../libs/fex-webuploader/dist/webuploader.min',
        'template': '../libs/art-template/lib/template-web',
        'sortable': '../libs/Sortable/Sortable.min',
        'ztree': '../libs/zTree/js/jquery.ztree.all.min',
        'kindeditor': '../libs/kindeditor/kindeditor-all-min',
        'kindeditor_zh_CN': '../libs/kindeditor/lang/zh-CN',
        'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
        'jquery-tagsinput': '../libs/jquery.tagsinput/src/jquery.tagsinput'

    },
    shim: {
        'bootstrap': ['jquery'],
        'axios': {
            exports: 'axios',
        },
        'validator-lang': ['validator-core'],
        'lightyear': ['jquery'],
        'perfect-scrollbar ': {deps: ['jquery'], exports: 'PerfectScrollbar'},
        'bootstrap-table': {
            deps: [
                'bootstrap',
//                'css!../libs/bootstrap-table/dist/bootstrap-table.min.css'
            ],
            exports: '$.fn.bootstrapTable'
        },
        'bootstrap-table-lang': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-mobile': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-advancedsearch': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-commonsearch': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-jumpto': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'webuploader': {
            deps: ['jquery'],
            exports: "WebUploader"
        },
        'upload': ['jquery', 'webuploader'],
        'ztree': {
            deps: ['jquery'],
            exports: "$.fn.zTree",
        },
        'kindeditor': {
            deps: ['jquery'],
            exports: 'KindEditor'
        },
        'kindeditor_zh_CN': [
            'kindeditor'
        ],
        'bootstrap-datetimepicker': ['moment/locale/zh-cn'],
        'jquery-tagsinput': {
            deps: ['jquery'],
            exports: 'tagsInput'
        },
    },
    waitSeconds: 30,
    charset: 'utf-8' // 文件编码
});

require(['jquery', 'bootstrap'], function ($, undefined) {
    //初始配置
    var Config = requirejs.s.contexts._.config.config;
    //将Config渲染到全局
    window.Config = Config;
    $(function () {
        require(['aojie'], function (Aojie) {
            require(['backend'], function (Backend) {
                //加载相应模块
                if (Config.js_name) {
                    require([Config.js_name], function (Controller) {
                        if (Controller.hasOwnProperty(Config.action_name)) {
                            Controller[Config.action_name]();
                        } else {
                            if (Controller.hasOwnProperty("_empty")) {
                                Controller._empty();
                            }
                        }
                    }, function (e) {
                        console.log('-------------JS加载错误信息开始-------------');
                        console.error(e);
                        console.log('-------------JS加载错误信息结束-------------');
                        // 这里可捕获模块加载的错误
                    });
                }
            })
        });
    });
});